﻿using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.IO;
using System.Text;

namespace T.FAS.Runtime.Base.Common
{
    public static class ZipManager
    {
        public static void ZipFolder(string folder, string zipFileName)
        {
            ZipFile.CreateFromDirectory(folder, zipFileName, CompressionLevel.Fastest, true);
        }

        public static void ZipFolderWithoutBaseDirectory(string folder, string zipFileName)
        {
            ZipFile.CreateFromDirectory(folder, zipFileName, CompressionLevel.Fastest, false);
        }

        public static void UnZipFolder(string zipFileName, string targetFolder)
        {
            if (Directory.Exists(targetFolder))
                Directory.Delete(targetFolder, true);
            ZipFile.ExtractToDirectory(zipFileName, targetFolder, Encoding.UTF8);
        }
    }
}
